(function(){
	angular.module('app').factory('dashCardService',dashCardServ);

	dashCardServ.$inject = ['util','$q'];
	function dashCardServ(util,$q){

		return {
			init:init,
			modelS:modelS, //带shop

			modelP:modelP //带price
		}
		function init(){}
		function modelS(config,catName){

			var defer = $q.defer();

			util.$get({
				url:'/marketconditions/statistic/getCategoryStatistic.htm',
				data:{
					catName:catName
				}
			}).then(function(resp){
				// console.log(resp);
				if(resp.value.length>0){
					var json = resp.value[0];


					angular.forEach(config, function(item,index){
						item.date = json.date.split(' ')[0];
						item.body = json[item.body];

						item.footer = typeof (item.footer) == 'undefined'?'':json[item.footer];
					});
				}else{
					angular.forEach(config, function(item,index){
						item.date = '';
						item.body = 0;

						item.footer = 0;
					});
				}
				defer.resolve();
			},function(resp){
				defer.reject();
			});

			return defer.promise;
		}

		function modelP(){}
	}
})();